<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <div id="app">
        <button v-on:click="count++">被点击了{{count}}次</button>

        <!--使用定义好的全局组件-->
        <counter></counter>
        <counter></counter>

        <!--使用定义好的局部组件-->
        <button-counter></button-counter>
        <button-counter></button-counter>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>

    <script>

        //// 定义全局组件，两个参数：1，组件名称。2，组件参数
        Vue.component("counter", {
            template: `<button v-on:click="count++">组件：被点击了{{count}}次</button>`,
            data() {
                return {
                    count: 0
                }

            }
        });

        //声明局部组件
        const buttonCounter = {
            template: `<button v-on:click="count++">组件：被点击了{{count}}次</button>`,
            data() {
                return {
                    count: 6
                }

            }
        };

        let app = new Vue({
            el: "#app",
            data: {
                count: 1
            },
            components:{
                "button-counter": buttonCounter
            }
        });
    </script>
</body>

</html>